#include <iostream>
#include <cstdint>
#include <cstring>

#include <boost/type_traits/is_unsigned.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_pod.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/static_assert.hpp>
#include <boost/array.hpp>

template <class T1, class T2>
void type_traits_examples(T1&, T2&) {
	std::cout << std::boolalpha;
	std::cout << "boost::is_unsigned<T1>::value:" << boost::is_unsigned<T1>::value << "    ";
	std::cout << "boost::is_same<T1, T2>::value:" << boost::is_same<T1, T2>::value << "    ";
	std::cout << std::endl;
}

template <class T, std::size_t BufSizeV>
void serialize2(const T& value, boost::array<unsigned char, BufSizeV>& buf)
{
	BOOST_STATIC_ASSERT_MSG(boost::is_pod<T>::value,
		"This serialize2 function may be used only with POD types");

	BOOST_STATIC_ASSERT_MSG(BufSizeV >= sizeof(value),
		"Can not fit value to buffer. Make buffer bigger.");

	std::memcpy(&buf[0], &value, sizeof(value));
}

int main()
{
	unsigned int a = 1;
	const unsigned int b = 2;
	std::cout << "==== 1 ====" << std::endl;
	type_traits_examples(a, b);

	boost::array<unsigned char, 20> buf;
	serialize2("Hello word", buf);
	return 0;
}